@extends('admin.main')
@section('content')
    <div class="admin-biaogelist">
        <div class="daohang">
            <ul>
                <li>
                    <button type="button" class="am-btn am-btn-default am-radius am-btn-xs"> 反馈管理</button>
                </li>
            </ul>
        </div>
        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 反馈列表</ul>

            <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">反馈列表</a></dl>

        </div>

        <form class="am-form am-g">
            <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
                <thead>
                <tr class="am-success">
                    <th class="table-id">ID</th>
                    <th class="table-type">建议内容</th>
                    <th class="table-author">用户名</th>
                    <th class="table-date am-hide-sm-only">反馈日期</th>
                    <th width="163px" class="table-set">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(!empty($res['data']))
                    @foreach($res['data'] as $v)
                        <tr >
                            <td>{{$v['id']}}</td>
                            <td><a href="#">{{$v['ask_content']}}</a></td>
                            <td class="am-hide-sm-only" id="tr_{{$v['id']}}">{{$v['username']}}</td>
                            <td class="am-hide-sm-only">{{$v['created_at']}}</td>
                            <td>@if($v['status']==0)<a href="javascript:void(0)" class="abtn" onclick="backResopen({{$v['user_id']}},{{$v['id']}})">回复</a>@else 已回复 @endif</td>
                        </tr>
                     @endforeach
                    @else
                    <tr><td colspan="5" align="center">暂无数据</td></tr>
                @endif
                </tbody>
            </table>
            @if(!empty($res['data']))
            <ul class="am-pagination am-fr">
                @if(isset($res['prev_page_url']))
                    <li><a href="{{$res['prev_page_url']}}">«</a></li>
                @endif
                @foreach($res['pageNoList'] as $v)
                    @if($res['current_page']==$v)
                    <li class="am-active"><a href="{{urlAdmin("response",'getList')}}?page={{$v}}">{{$v}}</a></li>
                    @else
                        <li><a href="{{urlAdmin("response",'getList')}}?page={{$v}}">{{$v}}</a></li>
                    @endif
                @endforeach
                @if(isset($res['next_page_url']))
                    <li><a href="{{$res['next_page_url']}}">»</a></li>
                @endif
            </ul>
             @endif
    @include('admin.footer')
    @section("script")
         <script type="text/javascript">
             function backResopen(id,offset){
                 var name = $('#tr_'+offset).html();
                 layer.open({
                     type: 1,
                     title:"问题反馈",
                     skin: 'layui-layer-rim', //加上边框
                     area: ['420px', '240px'], //宽高
                     content: '<div id="write_content"><div class="content_title">回馈 <span>'+name+'</span>用户</div><div id="content_inp"><textarea style="width: 100%; height: 80px; font-size: 13px;" id="con"></textarea><input type="hidden" value="'+offset+'" id="rep"></div><div class="s_btn"><input type="button" class="s" value="确认" onclick="confirm()"></div></div>'
                 });
             }

             /**
              * 确认发送
              */
             function confirm(){

                   var id = $("#rep").val();
                   var con = $("#con").val();
                   if (con==''){
                         layer.msg("回复内容不能为空!");
                         return
                   }
                   data = {id:id,con:con};
                   $.ajax({
                       type:"post",
                       url:"{{urlAdmin('response','postRespon')}}",
                       data:data,
                       dataType:"json",
                       success:function(data){
                             if (data['state']==1){
                                   layer.msg('回复成功');
                             }else{
                                   layer.msg('回复失败');
                             }
                       }
                   })
             }
         </script>
    @endsection
@endsection